﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace TestApp.Flowchart.Model
{
    [JsonObject(MemberSerialization.OptIn)]
    class LayerNode1 : FlowNode
    {
        public LayerNode1() { }

        public override FrameworkElement CreateContent()
        {
            var textBlock = base.CreateContent() as TextBlock;

            var canvas = new Canvas();

            var ui = new Border();

            ImageBrush b = new ImageBrush();
            b.ImageSource = new BitmapImage(new Uri("pack://application:,,,/Resources/layernode1.png", UriKind.Absolute));
            b.Stretch = Stretch.Fill;
            ui.Background = b;
            ui.Width = this.Width;
            ui.Height = this.Height;

            canvas.Children.Add(ui);


            Canvas.SetLeft(textBlock, this.Width / 2);
            Canvas.SetTop(textBlock, this.Height + 10);

            canvas.Children.Add(textBlock);

            return canvas;
        }

        public FlowNode Json2Obj(string value)
        {
            return JSONUtils.Json2Obj<LayerNode1>(value);
        }
    }
}
